#!/bin/ksh

LOGIN=$1
SH_DIR=$2
SH_FILE=$3
UP_DIR=$4
UP_FILE=$5

sqlplus -s $LOGIN<<!
DELETE FROM ccs.ccs_ams_tmp_aging;
COMMIT;
!

cat > $UP_DIR/ctl/$SH_FILE.ctl<<!
LOAD DATA
INFILE '$UP_DIR/$UP_FILE'
APPEND INTO TABLE CCS.CCS_AMS_TMP_AGING
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
(
SEQ_NO       SEQUENCE(MAX,1),
TEXTLINE
)
!
/usr/local/bin/dos2unix $UP_DIR/$UP_FILE
sqlldr $LOGIN \
control=$UP_DIR/ctl/$SH_FILE.ctl bad=$UP_DIR/bad/$SH_FILE.bad \
log=$UP_DIR/log/$SH_FILE.log >> $UP_DIR/log/$SH_FILE.log
